<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
<title>教学区域信息查询</title>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.pagination.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/public.js"></script>
<script type="text/javascript" src="../../js/validata.js"></script>
<script type="text/javascript" src="../../js/http.js"></script>
<script type="text/javascript" src="../../js/alert.js"></script>
<script type="text/javascript" src="../../js/loadSchoolGrade.js"></script>
<script type="text/javascript" src="../../js/jquery-ui/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../js/jquery-ui/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.css">
</head>
<body>
	<div>
		<form id="form1">
			<table class="table table-bordered .table-condensed">
				<tr>
					<td>编号:</td>
					<td id="seq"></td>
					<td>培训机构:</td>
					<td id="school">
					</td>
				</tr>
				<tr>
					<td>名称:</td>
					<td>						 
						<input type="text" name="name" class="required maxlength:50"/>
						<input type="hidden" name="id" id="id" />
					</td>
					<td>地址:</td>
					<td>
						<input type="text" name="address" class="required maxlength:150"/>
					</td>
				</tr>
				<tr>
					<td>可培训车型:</td>
					<td colspan="3">
						<!-- 可培训车型 vehicletype -->
						<label><input type="checkbox" id="vehicletype1" value="A1" class="minimal-red" />A1</label>
						<label><input type="checkbox" id="vehicletype2" value="A2" class="minimal-red" />A2</label>
						<label><input type="checkbox" id="vehicletype3" value="A3" class="minimal-red" />A3</label>
						<label><input type="checkbox" id="vehicletype4" value="B1" class="minimal-red" />B1</label>
						<label><input type="checkbox" id="vehicletype5" value="B2" class="minimal-red" />B2</label>
						<label><input type="checkbox" id="vehicletype7" value="C1" class="minimal-red" />C1</label>
						<label><input type="checkbox" id="vehicletype8" value="C2" class="minimal-red" />C2</label>
						<label><input type="checkbox" id="vehicletype9" value="C3" class="minimal-red" />C3</label>
						<label><input type="checkbox" id="vehicletype10" value="C4" class="minimal-red" />C4</label>
						<label><input type="checkbox" id="vehicletype11" value="C5" class="minimal-red" />C5</label>
						<label><input type="checkbox" id="vehicletype12" value="D" class="minimal-red" />D</label>
						<label><input type="checkbox" id="vehicletype13" value="E" class="minimal-red" />E</label>
						<label><input type="checkbox" id="vehicletype14" value="F" class="minimal-red" />F</label>
						<label><input type="checkbox" id="vehicletype15" value="M" class="minimal-red" />M</label>
						<label><input type="checkbox" id="vehicletype16" value="N" class="minimal-red" />N</label>
						<label><input type="checkbox" id="vehicletype17" value="P" class="minimal-red" />P</label>
						<input type="hidden" name="vehicletype" class="required"/>
					</td>
				</tr>
				<tr>
					<td>教学区域类型:</td>
					<td>
						<select name="type" style="width: 90px;">
							<option value="1">科目二</option>
							<option value="2">科目三</option>
						</select>
					</td>
					<td></td>
					<td></td>
				</tr>
				<tr>
					<td>可容纳车辆数:</td>
					<td>
						<input type="text" name="totalvehnum" maxlength="11" class="required onlyNum"/>
					</td>
					<td>已投放车辆数:</td>
					<td>
						<input type="text"name="curvehnum" maxlength="11" class="required onlyNum"/>
					</td>
				</tr>
				<tr>
					<td>教学区域面积(m²):</td>
					<td colspan="3">
						<input type="text" name="area" class="required onlyNum"/>
					</td>
				</tr>
				<tr>
					<td>教学区域空间坐标集合:</td>
					<td colspan="3">
						<input type="text" id="xys" name="polygon" readonly="readonly" class="required"/>
						<button type="button" onclick="setPolygon();" class="btn btn-danger">修改电子围栏</button>
					</td>
				</tr>
				<tr>
					<td>备注:</td>
					<td colspan="3">
                    	<input type="text" name="remark"/>
					</td>
				</tr>
				<tr>
					<td>启用标识:</td>
					<td id="flag"></td>
					<td>不同意启用的原因:</td>
					<td id="reason"></td>
				</tr>
				<tr>
					<td>流程:</td>
					<td id="flowBa"></td>
					<td>流程说明:</td>
					<td id="flowRemark"></td>
				</tr>
				
				<tr>
					<td colspan="4" style="text-align: center;" id="btnTd">
						<button type="button" onclick="updateRegion();" class="btn btn-info" >修改</button>
					</td>
				</tr>
			</table>
		</form>
	</div>
     
	<!-- 设置电子围栏 -->
	<div id="setPolygonInfoDiv" style="display:none;" title="设置电子围栏">
		<iframe src="" style="width:100%;height: 100%" frameborder="no" marginwidth="0" marginheight="0" allowtransparency="yes"></iframe>
	</div>
     
    <script type="text/javascript">
    	var xy = "";
		$(function(){
			var href = location.href.split("=");
			var regionId = href[1];

			getRegion(regionId);
		});
		

    	//查看教学区域信息
    	function getRegion(id){
    		$("input[type='checkbox']:checked").each(function(){
    			$(this).parent().click();
    		});
    		$.ajax({
    			url : "../../region/get.ao",
    			type : 'POST',
    			data :{
    				"id" : id
    			},
    			cache : false,
    			beforeSend : ajaxstar,
    			complete : ajaxend,
    			dataType : "json",
    			success : function(data) {
    				if (data["state"] == "success") {
    					if(data["result"]["flowBa"] == 99){//添加删除备案按钮
							var funPath = "..\\\\..\\\\http_region\\\\deleteRegionPutOnRecord.ao"; 
    						var delBaBtn = '<button type="button" onclick="baAn(\''+funPath+'\','+id+');" class="btn btn-danger">删除备案</button>';
    						$("#btnTd").append(delBaBtn);
    					}
    					$("table").find("td").each(function(){//不更改的字段
    						var id = $(this).attr("id");
    						if(id != null && typeof(id) != "undefined"){
    							$(this).html(data["result"][id]);
    						}
    					});
    					$("table").find("input").each(function(){//文本框内容
    						var name = $(this).attr("name");
    						if(name != null && typeof(name) != "undefined"){
    							if(name == "vehicletype"){//复选框选中
    								var vehicletypes = data["result"][name].split(",");
    								for (var i = 0; i < vehicletypes.length; i++) {
        								$("input[value='" + vehicletypes[i] + "']").parent().click();
    								}
    							}
    							$(this).val(data["result"][name]);
    							xy = data["result"]["polygon"];
    						}
    					});
    					$("table").find("select").each(function(){//下拉列表框
    						var name = $(this).attr("name");
    						if(name != null && typeof(name) != "undefined"){
    							$(this).val(data["result"][name]);//设置选中项
    						}
    					});
    				} else {
    					sAlert(data["result"]);
    				}
    			}
    		});
    	}
    	
    	//修改教学区域
    	function updateRegion(){
    		var vehicletype="";
    		$("#form1").find("input[id^='vehicletype']").each(function(){
    			var check = $(this).prop("checked");
    			if(check == true){
    				vehicletype += $(this).val()+",";
    			}
    		});
    		vehicletype = vehicletype.substr(0,vehicletype.length-1);
			$("input[name='vehicletype']").val(vehicletype);

			if(validata("form1")){
	       		$.ajax({
	       			url : "../../region/update.ao",
	       			type : 'POST',
	       			data :$("#form1").serialize(),
	       			cache : false,
	       			beforeSend : ajaxstar,
	       			complete : ajaxend,
	       			dataType : "json",
	       			success : function(data) {
	   					sAlert(data["result"]);
	       				if(data["state"] == "success"){
	       					location.reload();
	       				}
	       			}
	       		});
			}
    	}

		//设置电子围栏
		function setPolygon(){
			$("#setPolygonInfoDiv").find("iframe").attr("src","lookPolygon.html?xy="+xy);
			$("#setPolygonInfoDiv").dialog({
				title : "修改电子围栏",
				resizable : false,
				width : 850,
				height : 600,
				resizable : true,
				modal : true,
				buttons : {
					"关闭" : function() {
						$(this).dialog("close");
					}
				}
			});
		}
    	
    	//保存从设置电子围栏页传过来的坐标集
    	function setPolygonXy(xy){
    		$("#xys").val(xy);
    		$("#setPolygonInfoDiv").dialog("close");
    	}
    </script>
</body>
</html>